package com.exam.api.controller;

import com.exam.api.common.BaseController;
import com.exam.api.common.ReturnMsg;
import com.exam.api.dto.AdminDTO;
import com.exam.api.service.AdminService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
import com.exam.api.common.BaseSelectEntity;
import cn.hutool.core.collection.CollectionUtil;
import java.util.Date;
/**
* @description: 管理员对外接口层
* @author: wuming
* @create: 2024.05.03 13:24:03
*/
@RestController
@RequestMapping("/admin")
public class AdminController extends BaseController<AdminService, AdminDTO> {


    @Override
    @Resource(name = "adminService")
    protected void setBaseService(AdminService adminService) {
        this.baseService = adminService;
    }

    /**
    * 默认分页查询
    * @param adminDTO
    * @return
    */
    @PostMapping("/page")
    public ReturnMsg page(@RequestBody AdminDTO adminDTO) {
        return ReturnMsg.ok(baseService.basePage(adminDTO));
    }

    /**
    * 根据XML中的sql语句进行查询
    * @param adminDTO
    * @return
    */
    @PostMapping(value = "/findList")
    public ReturnMsg findList(@RequestBody AdminDTO adminDTO) {
        return ReturnMsg.ok(baseService.findList(adminDTO));
    }

    @Override
    protected void beforeSave(AdminDTO entity) throws Exception {
        entity.setCreateTime(new Date());
        super.beforeSave(entity);
    }

}

